<?php
namespace Common\Model;


class MessageModel extends BaseModel
{
    protected $_auto = [
        ['created_at', 'time', self::MODEL_INSERT, 'function'],
    ];

    protected $_validate = [
        ['title', 'require', '标题不可为空'],
        ['content', 'require', '内容不可为空'],
        ['rec_type', 'require', '接收群体不可为空'],
        ['sort', 'require', '排序不能为空'],

    ];

    protected $_scope = [
        'list' => [
            'where' => ['deleted_at' => ['exp', 'is null']],
        ],
        'detail' => [
            'where' => ['deleted_at' => ['exp', 'is null']],
        ]
    ];

    protected function _after_find(&$record, $options)
    {
        if (isset($record['content'])) {
            $record['content'] = html_entity_decode($record['content']);
        }


    }

    protected function _after_select(&$records, $options)
    {
        foreach ($records as &$record) {
            $this->_after_find($record, $options);
        }
    }






}
